package com.develop.skwen.electricgomall.home.list;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.develop.skwen.basemodule.list.BaseAdapter;
import com.develop.skwen.basemodule.list.BaseHolder;
import com.develop.skwen.electricgomall.R;
import com.develop.skwen.electricgomall.home.list.holder.AdHolder;
import com.develop.skwen.electricgomall.home.list.holder.ListHolder;
import com.develop.skwen.electricgomall.home.list.holder.RecommendHolder;
import com.develop.skwen.electricgomall.home.model.HomeData;

import java.util.List;

/**
 * Created by skwen
 * on 18-5-30
 */

public class HomeAdapter extends BaseAdapter<HomeData>{


    public HomeAdapter(List<HomeData> list) {
        super(list);
    }

    @Override
    public int getItemViewType(int position) {
        return getItem(position).getType();
    }

    @Override
    protected BaseHolder getViewHolder(LayoutInflater inflater, ViewGroup parent, int viewType) {
        switch (viewType){
            case 0:
                return new AdHolder(inflater.inflate(R.layout.home_list_holder_ad,parent,false));
            case 1:
                return new RecommendHolder(inflater.inflate(R.layout.home_list_holder_recommend,parent,false));
            case 2:
                return new ListHolder(inflater.inflate(R.layout.home_list_holder_item,parent,false));
        }
        return null;
    }
}
